<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE html>
<html lang="en">
  <head>
  	<base href="<%=basePath%>">
  	<!-- jsp文件头和头部 -->
  	<%@ include file="../../system/admin/top.jsp"%> 
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>患者信息</title>
    <script src="static/js/jquery-1.11.3.js"></script>
    <script src="static/js/bootstrap.min.js"></script>
    <script type="text/javascript" src="static/js/bootbox.min.js"></script>
    <script type="text/javascript">
		$(top.hangge());
		//新增
		function add(){
			 top.jzts();	//显示加载进度
			 var diag = new top.Dialog();
			 diag.Drag=true;
			 diag.Title ="新增";
			 diag.URL = '<%=basePath%>patient/goAddP.do';
	 		 diag.Width = 1000;
			 diag.Height = 800; 
			 diag.CancelEvent = function(){ //关闭事件
				 if(diag.innerFrame.contentWindow.document.getElementById('zhongxin').style.display == 'none'){
					 if('${page.currentPage}' == '0'){
						 top.jzts();
						 setTimeout("self.location=self.location",100);
					 }else{
						 nextPage(${page.currentPage});
					 }
				}
				diag.close();
			 };
			 diag.show();
		}
		
		//修改
		function edit(hzId){
			 top.jzts();	//显示加载进度
			 var diag = new top.Dialog();
			 diag.Drag=true;
			 diag.Title ="修改";
			 diag.URL = '<%=basePath%>patient/goEdit?hzId='+hzId;
	 		 diag.Width = 1000;
			 diag.Height = 800; 
			 diag.CancelEvent = function(){ //关闭事件
				 if(diag.innerFrame.contentWindow.document.getElementById('zhongxin').style.display == 'none'){
					 if('${page.currentPage}' == '0'){
						 top.jzts();
						 setTimeout("self.location=self.location",100);
					 }else{
						 nextPage(${page.currentPage});
					 }
				}
				diag.close();
			 };
			 diag.show();
		}
		
		//删除
		function deleteP(patientId,msg){
			bootbox.confirm("确定要删除["+msg+"]吗?", function(result) {
				if(result) {
					top.jzts();
					var _url = "<%=basePath%>patient/deleteP.do";
					$.ajax({
							type: "POST",
							url: _url,
					    	data: {hzId:patientId},
							dataType:'json',
							//beforeSend: validateData,
							cache: false,
							success: function(data){
								 if(data.msg=="success"){
								 	alert("删除成功");
								 	$(top.hangge());
								 	window.location.reload(true);
								 	nextPage(${page.currentPage});
								 }else{
								 	alert(data.msg);
								 	$(top.hangge());
								 	window.location.reload(true);
								 }
							}
						});
					/* $.get(url,function(data){
						console.info(data);
						nextPage(${page.currentPage});
					}); */
				}
			});
		}
	</script>
	<style>
    	.btn-success,
    	.btn-danger {
    		padding-top:0;
    		text-align:center;
    	}
    	.table th,
    	.table td {
    		text-align:center;
    		vertical-align:middle;
    	}
    	form {
		    margin: 0;
		    margin-top:10px;
		}
    </style>
</head>
  <body>
    <div class="container-fluid" style="padding-left:0;padding-right:40px;">
    	<!-- 检索  -->
		<form action="patient/list.do" method="post" name="userForm" id="userForm">
			<table>
				<tr>
					<td>
						<span class="input-icon">
							<input autocomplete="off" id="nav-search-input" type="text" name="name" value="${pd.name}" placeholder="这里输入姓名" />
							<i id="nav-search-icon" class="icon-search"></i>
						</span>
					</td>
					<td>
						<span class="input-icon">
							<input autocomplete="off" id="phone" type="text" name="phone" value="${pd.phone}" placeholder="这里输入电话" />
							<i id="nav-search-icon2" class="icon-search"></i>
						</span>
					</td>
					<td style="vertical-align:top;"><button class="btn btn-mini btn-light" onclick="search();" title="检索"><i id="nav-search-icon" class="icon-search"></i></button></td>
				</tr>
			</table>
		</form>
		<!-- 检索  -->
        <table id="table_report" class="table table-striped table-bordered table-hover">
			<thead>
				<tr>
					<th class="center">
						<label><input type="checkbox" id="zcheckbox" /><span class="lbl"></span></label>
					</th>
					<th>序号</th>
					<th>姓名</th>
					<th>患者来源</th>
					<th>性别</th>
					<th>年龄</th>
					<th>电话</th>
					<th>时间</th>
					<th class="center">操作</th>
				</tr>
			</thead>
			<tbody>
				<!-- 开始循环 -->	
				<c:choose>
					<c:when test="${not empty allPatients}">
						<c:forEach items="${allPatients}" var="patient" varStatus="vs">
							<tr>
								<td class='center' style="width: 30px;">
									<label><input type='checkbox' readonly /><span class="lbl"></span></label>
								</td>
								<td class='center' style="width: 30px;">${vs.index+1}</td>
								<td>${patient.name }</td>
								<td>${patient.hzly }</td>
								<td>${patient.sex }</td>
								<td>${patient.age }</td>
								<td>${patient.phone }</td>
								<td>${patient.updatedate }</td>
								<td style="width:100px;"><a class='btn btn-mini btn-info' title="编辑" onclick="edit(${patient.id});" >编辑</a>
									&nbsp;&nbsp;<a class='btn btn-mini btn-danger' title="删除" onclick="deleteP('${patient.id}','${patient.name}');" >删除</a>
								</td>
							</tr>
						</c:forEach>
					</c:when>
					<c:otherwise>
						<tr class="main_info">
							<td colspan="10" class="center">没有相关数据</td>
						</tr>
					</c:otherwise>
				</c:choose>
			</tbody>
		</table>
		<div class="page-header position-relative">
			<table style="width:100%;">
				<tr>
					<td style="vertical-align:top;"><a class="btn btn-small btn-success" onclick="add();">新增</a></td>
					<td style="vertical-align:top;"><div class="pagination" style="float: right;padding-top: 0px;margin-top: 0px;">${page.pageStr}</div></td>
				</tr>
			</table>
		</div>
     </div>
  </body>
</html>